package com.twu.biblioteca;

import sun.tools.tree.SwitchStatement;

import java.security.KeyStore;
import java.util.*;

public class BibliotecaApp {

    private final String WELCOME_MESSAGE = "Welcome To Biblioteca App, We Are Happy To Serve You";
    private final String INVALID_OPTION_MESSAGE = "Invalid Option Selected";



    Library library = new Library();
    public static void main(String[] args) {
      BibliotecaApp bibliotecaApp = new BibliotecaApp();
      //Map <Integer,String> menu = bibliotecaApp.menuList();
      System.out.println(bibliotecaApp.welcomeMessage());

        Scanner userInput = new Scanner( System.in );
        Integer bookId = 0;
        String customerName="";
        Integer menuItem = 0;

       // menuItem = menuListItem(menu,bibliotecaApp);
    }

    private static void checkoutAndReturnBook(BibliotecaApp bibliotecaApp, Integer menuItem) {
        Integer bookId;
        String customerName;
        String movieTitle;
        Movie movie;

        Scanner userInput = new Scanner( System.in );
        //Map <Integer,String> menu = bibliotecaApp.menuList();
        switch (menuItem){
            case  1:System.out.println("Please Enter A Book Id");
                    bookId = userInput.nextInt();
                    System.out.println("Please Enter Your Name");
                    customerName = userInput.next();
                    //System.out.println(bibliotecaApp.successfulBookCheckout(bookId,customerName));
                    break;
            case 2:System.out.println("Please Enter A Book Id");
                   bookId = userInput.nextInt();
                   //System.out.println(bibliotecaApp.bookReturnSuccessfulMessage(bookId));
                   break;
            case 3:System.out.println("Please Enter The Movie Title");
                   movieTitle = userInput.next();
                   System.out.println("Please Enter Your Name");
                   customerName = userInput.next();
                   //movie= Library.movieForCheckout(movieTitle);
                   //System.out.println(Library.checkoutMovieReturnMessage(movie,customerName));

            case 4:System.exit(0);
                break;
        }
        //menuListItem(menu, bibliotecaApp);
    }

    private static void checkValidOptionSelected(BibliotecaApp bibliotecaApp, Integer menuItem) {
        //Map <Integer,String> menu = bibliotecaApp.menuList();
        if(bibliotecaApp. selectMenuOption(menuItem) == bibliotecaApp.INVALID_OPTION_MESSAGE){
            System.out.println(bibliotecaApp.INVALID_OPTION_MESSAGE);
            //menuListItem(menu,bibliotecaApp);
        }
        else
        {
            checkoutAndReturnBook(bibliotecaApp, menuItem);
        }
    }

    private static Integer menuListItem(Map<Integer, String> menu,BibliotecaApp bibliotecaApp) {
        Scanner userInput = new Scanner( System.in );
        //Map <Integer,String> books = bibliotecaApp.ListOfBooks();
        //availableBooks(books);
        System.out.println("Please Select a menu item");
        for (Map.Entry<Integer, String> entry : menu.entrySet()) {
            Integer key = entry.getKey() ;
            String value = entry.getValue();
            System.out.println(key + " " + value);
        }
        Integer menuItem = userInput.nextInt();
        checkValidOptionSelected(bibliotecaApp, menuItem);
        return menuItem;
    }

    private static void availableBooks(Map<Integer, String> books) {
        System.out.println("We have the following books \n");

        for (Map.Entry<Integer, String> entry : books.entrySet()) {
          Integer key = entry.getKey() ;
          String value = entry.getValue();
          System.out.println(key + " " + value);
        }
    }

    public String welcomeMessage() {
        return WELCOME_MESSAGE;
    }



    public String selectMenuOption(int i) {
        String message = "";
        //Map<Integer, String> menuList = library.menuList;
        //if(!menuList.containsKey(i))
        //{
          //  message = INVALID_OPTION_MESSAGE;
        //}

        return message;
    }




}
